package com.util;

import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    public Result() {
    }

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static Result ok(){
        Result result=new Result(200,"操作成功",null);
        return result;
    }
    public static Result ok(Object data){
        Result result=new Result(200,"操作成功",data);
        return result;
    }
    public static Result ok(Object data,String msg){
        Result result=new Result(200,msg,data);
        return result;
    }
    public static Result error(){
        Result result=new Result(500,"操作失败",null);
        return result;
    }
    public static Result error(Integer code){
        Result result=new Result(code,"操作失败",null);
        return result;
    }
    public static Result error(Integer code,String msg){
        Result result=new Result(code,msg,null);
        return result;
    }
}
